package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Zreturnedgood;
import cn.gson.fengboot.model.pojos.Zreturnedgooddetail;
import cn.gson.fengboot.model.service.ZorderService;
import cn.gson.fengboot.model.service.ZreturnedgoodService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/thdan")
public class ZreturnedgoodController {
    @Autowired
    ZreturnedgoodService ddservice;

    //订单弹出框查询方法
    @RequestMapping("/list_thd")
    @ResponseBody
    public Map<String,Object> kaipiao(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.ddlist(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //订单弹出框查询方法
    @RequestMapping("/list_thd2")
    @ResponseBody
    public Map<String,Object> kaipiao2(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.ddlist2(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //订单详情退货单
    @RequestMapping("/dd_thd")
    @ResponseBody
    public List<Zreturnedgood> ddthd(String search){

        return ddservice.ddthd(search);
    }


    //退货单弹框
    @RequestMapping("/thtk")
    @ResponseBody
    public Map<String,Object> thtk(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.thtk(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }


    //退货单产品详情
    @RequestMapping("/thdcp")
    @ResponseBody
    public List<Zreturnedgooddetail> thdcp(String search){

        return ddservice.thdxq(search);
    }

    //退货单新增方法
    @RequestMapping("/add_thd")
    @ResponseBody
    public void xz(@RequestBody Zreturnedgood th){
        ddservice.xz(th);
    }


}
